import { PUSH_STATE_STATUS_OPTIONS } from '@/constant'
import { ORDER_SOURCE_OPTIONS, RESERVE_INVOICE_STATUS_OPTIONS } from '@/constant/purchase'
import { Empty } from 'antd'
export const searchConfig = ({
  DICTDATA,
  classBig,
  SupplierOption,
  SkuOptions,
  handleSearchSupplier,
  UserOptions,
  handleSearchUser,
  SpuOptions,
  handleSearchSpuOptions,
  isRoot,
}: {
  DICTDATA: IDICTDATAType
  classBig: IOptionItem[]
  SupplierOption: IOptionItem[]
  SkuOptions: IOptionItem[]
  handleSearchSupplier: (newvalue: string) => void
  UserOptions: IOptionItem[]
  handleSearchUser: (newvalue: string) => void
  SpuOptions: IOptionItem[]
  handleSearchSpuOptions: (newvalue: string) => void
  isRoot: boolean
}): IItemArray[] => {
  return [
    {
      label: '预约发货单号',
      name: 'reserveInvoiceCodes',
      placeholder: '多个单号间需要换行或使用","分隔',
      type: 'Select',
      config: {
        mode: 'tags',
        maxTagCount: 'responsive',
        tokenSeparators: [',', '，', '\n', '\r', '\r\n'],
        notFoundContent: null,
      },
    },
    { label: '制单时间', name: 'createTimeStart', type: 'FixedRangePicker', config: { showTime: true } },
    {
      label: '订单状态',
      name: 'reserveInvoiceStatuses',
      type: 'Select',
      option: RESERVE_INVOICE_STATUS_OPTIONS,
      config: {
        suffixIcon: null,
        showSearch: true,
        optionFilterProp: 'label',
        mode: 'multiple',
        maxTagCount: 'responsive',
      },
    },
    {
      label: '预约发货时间',
      name: 'scheduleDeliveryTimeStart',
      type: 'FixedRangePicker',
      config: { showTime: true },
    },
    {
      label: '大类',
      name: 'bigClassIds',
      type: 'Select',
      option: classBig,
      config: {
        mode: 'multiple',
        maxTagCount: 'responsive',
        optionFilterProp: 'label',
      },
    },
    {
      name: 'supplierIds',
      label: '供应商',
      type: 'Select',
      option: SupplierOption,
      config: {
        suffixIcon: null,
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: false,
        mode: 'multiple',
        maxTagCount: 'responsive',
        onSearch: handleSearchSupplier,
        notFoundContent: <Empty description="请输入内容搜索" image={Empty.PRESENTED_IMAGE_SIMPLE} />,
      },
    },
    {
      label: '采购订单号',
      name: 'purchaseOrderCodes',
      placeholder: '多个单号间需要换行或使用","分隔',
      type: 'Select',
      config: {
        mode: 'tags',
        maxTagCount: 'responsive',
        tokenSeparators: [',', '，', '\n', '\r', '\r\n'],
        notFoundContent: null,
      },
    },
    {
      label: '年份',
      name: 'year',
      type: 'FixedDatePicker',
      placeholder: '请选择年份',
      config: {
        picker: 'year',
        format: 'YYYY',
        customFormat: 'YYYY',
      },
    },
    {
      name: 'seasonCode',
      label: '订单季节',
      type: 'Select',
      option: DICTDATA.order_season,
      placeholder: '请选择订单季节',
      config: {
        showSearch: true,
        optionFilterProp: 'label',
      },
    },
    {
      label: '预计到货时间',
      name: 'estimatedArrivalTimeStart',
      type: 'FixedRangePicker',
      config: { showTime: true },
    },
    { label: '实际到货时间', name: 'lastArrivalTimeStart', type: 'FixedRangePicker', config: { showTime: true } },
    { label: '订单来源', name: 'orderSources', type: 'Select', option: ORDER_SOURCE_OPTIONS },
    {
      label: '供应链跟单',
      name: 'trackOrderPerson',
      type: 'Select',
      option: UserOptions,
      hidden: !isRoot,
      config: {
        suffixIcon: null,
        showSearch: true,
        optionFilterProp: 'label',
        filterOption: false,
        onSearch: handleSearchUser,
        notFoundContent: <Empty description="请输入内容搜索" image={Empty.PRESENTED_IMAGE_SIMPLE} />,
        fieldNames: { label: 'label', value: 'workId' },
      },
    },
    {
      label: 'SPU商品',
      name: 'spuCode',
      type: 'Select',
      option: SpuOptions,
      placeholder: '款式编码/款式名称/助记码',
      config: {
        suffixIcon: null,
        showSearch: true,
        filterOption: false,
        optionFilterProp: 'label',
        onSearch: handleSearchSpuOptions,
        notFoundContent: <Empty description="请输入内容搜索" image={Empty.PRESENTED_IMAGE_SIMPLE} />,
      },
    },
    {
      label: 'SKU商品',
      name: 'skuCodeList',
      placeholder: '商品条码',
      type: 'Select',
      option: SkuOptions,
      config: {
        mode: 'tags',
        maxTagCount: 'responsive',
        notFoundContent: null,
      },
    },
    {
      label: '推送状态',
      name: 'pushStatus',
      type: 'Select',
      option: PUSH_STATE_STATUS_OPTIONS,
      hidden: !isRoot,
    },
    {
      label: '物流需求单号',
      name: 'transportationOrderCode',
      type: 'Input',
      placeholder: '请输入物流需求单号',
    },
    {
      label: '运单号',
      name: 'wayBillNo',
      type: 'Input',
      placeholder: '请输入运单号',
    },
  ]
}
